package com.yun.yun;

import android.os.Environment;

import com.weteco.android.IDCReader.IDCReaderSDK;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;
//import com.weteco.android.IDCReader.IDCReaderSDK;

public class IDCardMsg {
	//姓名|性别|民族|出生日期|住址|公民身份号码|签发机关|有效期起始日期|有效期截止日期|预留区|指纹信息|
	//英文姓名|性别|永久居留证号码|国籍或所在地代码|中文姓名|证件签发日期|证件终止日期|出生日期|证件版本号|单次申请受理机关代码|证件类型标识(I)|预留项|指纹信息|
	//姓名|性别|出生日期|住址|公民身份号码|签发机关|有效期起始日期|有效期截止日期|通行证号码|签发次数|证件类型标识(J)|指纹信息|
	private static final String PATH = Environment.getExternalStorageDirectory().getPath();
	private String Name="";
	private String EngName="";//英文姓名
	private String Sex="";
	private String SexCode="";
	private String Nation="";
	private String NationCode="";
	private String Birthday="";
	private String Addr="";
	private String ID="";//公民身份号码 永久居留证号码
	private String IDNum="";//旧版永居证号码
	private String Issue="";//签发机关  单次申请受理机关代码
	private String StartDate="";
	private String EndDate="";
	private String Reverse="";//预留区
	private String Figner="";
	private String Nationality="";//国籍
	private String NationalityCode="";//国籍代码
	private String IDVer="";//证件版本
	private String IDType="";//证件类型标识(I)
	private String SignNum="";//签发次数
	private String PassID="";//通行证号码
	private String zpPath = IDCReaderSDK.bmpPath;//身份证照片路径
	private String Reverse2="";//预留区2
	
	public String getZpPath() {
		return zpPath;
	}

	public void setZpPath(String zpPath) {
		this.zpPath = zpPath;
		IDCReaderSDK.bmpPath = zpPath;
	}

	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	public String getEngName() {
		return EngName;
	}

	public void setEngName(String engName) {
		EngName = engName;
	}

	public String getSex() {
		return Sex;
	}

	public void setSex(String sex) {
		Sex = sex;
	}

	public String getNation() {
		return Nation;
	}

	public void setNation(String nation) {
		Nation = nation;
	}

	public String getBirthday() {
		return Birthday;
	}

	public void setBirthday(String birthday) {
		Birthday = birthday;
	}

	public String getAddr() {
		return Addr;
	}

	public void setAddr(String addr) {
		Addr = addr;
	}

	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getIssue() {
		return Issue;
	}

	public void setIssue(String issue) {
		Issue = issue;
	}

	public String getStartDate() {
		return StartDate;
	}

	public void setStartDate(String startDate) {
		StartDate = startDate;
	}

	public String getEndDate() {
		return EndDate;
	}

	public void setEndDate(String endDate) {
		EndDate = endDate;
	}

	public String getReverse() {
		return Reverse;
	}

	public void setReverse(String reverse) {
		Reverse = reverse;
	}

	public String getFigner() {
		return Figner;
	}

	public void setFigner(String figner) {
		Figner = figner;
	}

	public String getNationality() {
		return Nationality;
	}

	public void setNationality(String nationality) {
		Nationality = nationality;
	}

	public String getIDVer() {
		return IDVer;
	}

	public void setIDVer(String iDVer) {
		IDVer = iDVer;
	}

	public String getIDType() {
		return IDType;
	}

	public void setIDType(String iDType) {
		IDType = iDType;
	}

	public String getSignNum() {
		return SignNum;
	}

	public void setSignNum(String signNum) {
		SignNum = signNum;
	}

	public String getPassID() {
		return PassID;
	}

	public void setIDNum(String idnum) {
		IDNum = idnum;
	}
	public String getIDNum() {
		return IDNum;
	}

	public String getSexCode() {
		return SexCode;
	}

	public String getNationCode() {
		return NationCode;
	}

	//16进制转成16进制字符串
	 public static String bytesToHexString(byte[] src,int srclen){
	        StringBuilder stringBuilder = new StringBuilder("");
	        if (src == null || src.length <= 0) {
	            return null;
	        }
	        for (int i = 0; i < srclen; i++) {
	            int v = src[i] & 0xFF;
	            String hv = Integer.toHexString(v);
	            if (hv.length() < 2) {
	                stringBuilder.append(0);
	            }
	            stringBuilder.append(hv);
	        }
	        return stringBuilder.toString();
	 }
	 //名族代码
	 private static  String[] NATION_TABLE = {
			"未知", "汉", "蒙古", "回", "藏", "维吾尔", "苗", "彝", "壮", "布依",
			"朝鲜", "满", "侗", "瑶", "白", "土家", "哈尼", "哈萨克", "傣", "黎",
			"傈僳", "佤", "畲", "高山", "拉祜", "水", "东乡", "纳西", "景颇", "柯尔克孜",
			"土", "达斡尔", "仫佬", "羌", "布朗", "撒拉", "毛南", "仡佬", "锡伯", "阿昌",
			"普米", "塔吉克", "怒", "乌孜别克", "俄罗斯", "鄂温克", "德昂", "保安", "裕固", "京",
			"塔塔尔", "独龙", "鄂伦春", "赫哲", "门巴", "珞巴", "基诺","穿青人","其他", "外国血统中国籍人士","外籍人员","未知"};
	//国籍代码
	private static String NATIONALITY_TABLE[][] = {
			{"AFG","阿富汗"},
			{"ALB","阿尔巴尼亚"},
			{"DZA","阿尔及利亚"},
			{"ASM","美属萨摩亚"},
			{"AND","安道尔"},
			{"AGO","安哥拉"},
			{"AIA","安圭拉"},
			{"ATA","南极洲"},
			{"ATG","安提瓜和巴布达"},
			{"ARG","阿根廷"},
			{"ARM","亚美尼亚"},
			{"ABW","阿鲁巴"},
			{"AUS","澳大利亚"},
			{"AUT","奥地利"},
			{"AZE","阿塞拜疆"},
			{"BHS","巴哈马"},
			{"BHR","巴林"},
			{"BGD","孟加拉国"},
			{"BRB","巴巴多斯"},
			{"BLR","白俄罗斯"},
			{"BEL","比利时"},
			{"BLZ","伯利兹"},
			{"BEN","贝宁"},
			{"BMU","百慕大"},
			{"BTN","不丹"},
			{"BOL","玻利维亚"},
			{"BIH","波黑"},
			{"BWA","博茨瓦纳"},
			{"BVT","布维岛"},
			{"BRA","巴西"},
			{"IOT","英属印度洋领土"},
			{"BRN","文莱"},
			{"BGR","保加利亚"},
			{"BFA","布基纳法索"},
			{"BDI","布隆迪"},
			{"KHM","柬埔寨"},
			{"CMR","喀麦隆"},
			{"CAN","加拿大"},
			{"CPV","佛得角"},
			{"CYM","开曼群岛"},
			{"CAF","中非"},
			{"TCD","乍得"},
			{"CHL","智利"},
			{"CHN","中国"},
			{"HKG","香港"},
			{"MAC","澳门"},
			{"TWN","台湾"},
			{"CSR","圣诞岛"},
			{"CCK","科科斯(基林)群岛"},
			{"COL","哥伦比亚"},
			{"COM","科摩罗"},
			{"COG","刚果（布）"},
			{"COD","刚果（金）"},
			{"COK","库克群岛"},
			{"CR","斯达黎加"},
			{"CIV","科特迪瓦"},
			{"HRV","克罗地亚"},
			{"CUB","古巴"},
			{"CYP","塞浦路斯"},
			{"CZE","捷克"},
			{"DNK","丹麦"},
			{"DJI","吉布提"},
			{"DMA","多米尼克"},
			{"DOM","多米尼加共和国"},
			{"TMP","东帝汶"},
			{"ECU","厄瓜多尔"},
			{"EGY","埃及"},
			{"SLV","萨尔瓦多"},
			{"GNQ","赤道几内亚"},
			{"ERI","厄立特里亚"},
			{"EST","爱沙尼亚"},
			{"ETH","埃塞俄比亚"},
			{"FLK","福克兰群岛(马尔维纳斯)"},
			{"FRO","法罗群岛"},
			{"FJI","斐济"},
			{"FIN","芬兰"},
			{"FRA","法国"},
			{"GUF","法属圭亚那"},
			{"PYF","法属波利尼西亚"},
			{"ATF","法属南部领土"},
			{"GAB","加蓬"},
			{"GMB","冈比亚Gambia"},
			{"GEO","格鲁吉亚"},
			{"DEU","德国"},
			{"GHA","加纳"},
			{"GIB","直布罗陀"},
			{"GRC","希腊"},
			{"GRL","格陵兰"},
			{"GRD","格林纳达"},
			{"GLP","瓜德罗普"},
			{"GUM","关岛"},
			{"GTM","危地马拉"},
			{"GIN","几内亚"},
			{"GNB","几内亚比绍"},
			{"GUY","圭亚那"},
			{"HTI","海地"},
			{"HMD","赫德岛和麦克唐纳岛"},
			{"HND","洪都拉斯"},
			{"HUN","匈牙利"},
			{"ISL","冰岛"},
			{"IND","印度"},
			{"IDN","印度尼西亚"},
			{"IRN","伊朗"},
			{"IRQ","伊拉克"},
			{"IRL","爱尔兰"},
			{"ISR","以色列"},
			{"ITA","意大利"},
			{"JAM","牙买加"},
			{"JPN","日本"},
			{"JOR","约旦"},
			{"KAZ","哈萨克斯坦"},
			{"KEN","肯尼亚"},
			{"KIR","基里巴斯"},
			{"PRK","朝鲜"},
			{"KOR","韩国"},
			{"KWT","科威特"},
			{"KGZ","吉尔吉斯斯坦"},
			{"LAO","老挝"},
			{"LVA","拉脱维亚"},
			{"LBN","黎巴嫩"},
			{"LSO","莱索托"},
			{"LBR","利比里亚"},
			{"LBY","利比亚"},
			{"LIE","列支敦士登"},
			{"LTU","立陶宛"},
			{"LUX","卢森堡"},
			{"MKD","前南马其顿"},
			{"MDG","马达加斯加"},
			{"MWI","马拉维"},
			{"MYS","马来西亚"},
			{"MDV","马尔代夫"},
			{"MLI","马里"},
			{"MLT","马耳他"},
			{"MHL","马绍尔群岛"},
			{"MTQ","马提尼克"},
			{"MRT","毛里塔尼亚"},
			{"MUS","毛里求斯"},
			{"MYT","马约特"},
			{"MEX","墨西哥"},
			{"FSM","密克罗尼西亚联邦"},
			{"MDA","摩尔多瓦"},
			{"MCO","摩纳哥"},
			{"MNG","蒙古"},
			{"MSR","蒙特塞拉特"},
			{"MAR","摩洛哥"},
			{"MOZ","莫桑比克"},
			{"MMR","缅甸"},
			{"NAM","纳米比亚"},
			{"NRU","瑙鲁"},
			{"NPL","尼泊尔"},
			{"NLD","荷兰"},
			{"ANT","荷属安的列斯"},
			{"NCL","新喀里多尼亚"},
			{"NZL","新西兰"},
			{"NIC","尼加拉瓜"},
			{"NER","尼日尔"},
			{"NGA","尼日利亚"},
			{"NIU","纽埃"},
			{"NFK","诺福克岛"},
			{"MNP","北马里亚纳"},
			{"NOR","挪威"},
			{"OMN","阿曼"},
			{"PAK","巴基斯坦"},
			{"PLW","帕劳"},
			{"PST","巴勒斯坦"},
			{"PAN","巴拿马"},
			{"PNG","巴布亚新几内亚"},
			{"PRY","巴拉圭"},
			{"PER","秘鲁"},
			{"PHL","菲律宾"},
			{"PCN","皮特凯恩群岛"},
			{"POL","波兰"},
			{"PRT","葡萄牙"},
			{"PRI","波多黎各"},
			{"QAT","卡塔尔"},
			{"REU","留尼汪"},
			{"ROM","罗马尼亚"},
			{"RUS","俄罗斯联邦"},
			{"RWA","卢旺达"},
			{"SHN","圣赫勒拿"},
			{"KNA","圣基茨和尼维斯"},
			{"LCA","圣卢西亚"},
			{"SPM","圣皮埃尔和密克隆"},
			{"VCT","圣文森特和格林纳丁斯"},
			{"WSM","萨摩亚"},
			{"SMR","圣马力诺"},
			{"STp","圣多美和普林西比"},
			{"SAU","沙特阿拉伯"},
			{"SEN","塞内加尔"},
			{"SYC","塞舌尔"},
			{"SLE","塞拉利昂"},
			{"SGP","新加坡"},
			{"SVK","斯洛伐克"},
			{"SVN","斯洛文尼亚"},
			{"SLB","所罗门群岛"},
			{"SOM","索马里"},
			{"ZAF","南非"},
			{"SGS","南乔治亚岛和南桑德韦奇岛"},
			{"ESP","西班牙"},
			{"LKA","斯里兰卡"},
			{"SDN","苏丹"},
			{"SUR","苏里南"},
			{"SJM","斯瓦尔巴群岛"},
			{"SWZ","斯威士兰"},
			{"SWE","瑞典"},
			{"CHE","瑞士"},
			{"SYR","叙利亚"},
			{"TJK","塔吉克斯坦"},
			{"TZA","坦桑尼亚"},
			{"THA","泰国"},
			{"TGO","多哥"},
			{"TKL","托克劳"},
			{"TON","汤加"},
			{"TTO","特立尼达和多巴哥"},
			{"TUN","突尼斯"},
			{"TUR","土耳其"},
			{"TKM","土库曼斯坦"},
			{"TCA","特克斯科斯群岛"},
			{"TUV","图瓦卢"},
			{"UGA","乌干达"},
			{"UKR","乌克兰"},
			{"ARE","阿联酋"},
			{"GBR","英国"},
			{"USA","美国"},
			{"UMI","美国本土外小岛屿"},
			{"URY","乌拉圭"},
			{"UZB","乌兹别克斯坦"},
			{"VUT","瓦努阿图"},
			{"VAT","梵蒂冈"},
			{"VEN","委内瑞拉"},
			{"VNM","越南"},
			{"VGB","英属维尔京群岛"},
			{"VIR","美属维尔京群岛"},
			{"WLF","瓦利斯和富图纳"},
			{"ESH","西撒哈拉"},
			{"YEM","也门"},
			{"YUG","南斯拉夫"},
			{"ZMB","赞比亚"},
			{"ZWE","津巴布韦"}
		};

	 private static String getNationality(String Nationality){
		 String str ="";
		 int len = NATIONALITY_TABLE.length;
		 for(int i = 0;i < len;i++){
			 if(Nationality.endsWith(NATIONALITY_TABLE[i][0])){
				 str = NATIONALITY_TABLE[i][1];
				 return str;
			 }
		 }
		 return str;
	 }
	 private static String getNation(int code){
		 if(code <= 56){
		 	return NATION_TABLE[code];//01 汉族
		 }else if(code == 81 || code == 59){
			 return NATION_TABLE[57];//穿青人
		 }else if(code == 97 || code == 57){
			 return NATION_TABLE[58];//其他
		 }else if(code == 98){
			 return NATION_TABLE[59];//外国血统中国籍人
		 }else if(code == 99 || code == 58){
			 return NATION_TABLE[60];//外籍人员
		 }else if(code == 94 ){
			 return "芒人";//芒人
		 }else if(code == 95 ){
			 return "摩梭人";//摩梭人
		 }else if(code == 96 ){
			 return "亻革家人";//ge（亻革）家人
		 }
		 else{
			 return NATION_TABLE[61];//未知
		 }
	 }
	public int BCC731(String src){
		String s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

		int []w = new int[]{7,3,1};
		int c = 0;
		for (int i = 0;i < src.length();i++){
			if (src.charAt(i) == '<')
				continue;
			c += s.indexOf(src.charAt(i))*w[i%3];
		}
		c %= 10;
		return c;
	}
	public String CalForeignerID(String citizenship,String idNumber,String reserved)
	{
		String IDNum;
		String temp;
		int bcc = 0,num = 3,multiple = 1;
		num = 3*multiple;//1-3国家和地区代码(拉丁字母)
		IDNum = citizenship.substring(0,num);

		num = 2*multiple;
		temp = idNumber.substring(1*multiple,1*multiple + num);//4-5首次申领地行政区域代码
		IDNum += temp;

		num = 2*multiple;
		temp = reserved.substring(0,num);//6-7首次申领地所属的行政区域代码
		IDNum += temp;

		num = 6*multiple;
		temp = idNumber.substring(8*multiple,8*multiple + num);//8-13出生日期
		IDNum += temp;

		num = 1*multiple;
		temp = reserved.substring(2*multiple,2*multiple + num);//14 顺序码
		IDNum += temp;

		bcc = BCC731(IDNum);

		IDNum += Integer.toString(bcc);//731 校验码

		return IDNum;
	}
	 public  int ParseIDMsg(byte []pucCHMsg,int len){
		 //UNICODE16 小端模式
		 //不带长度 不带状态码 只有数据
		 //文字信息长度256字节
		if(pucCHMsg.length < 256 || len != 256){
			 return -1;
		}
		byte[] tempData = new byte[120];
		String tempStr;
		try {
			//
			Arrays.fill(tempData, (byte)0x00);
			System.arraycopy(pucCHMsg, 248, tempData, 0, 2);

			IDType = new String(tempData,"UTF-16LE");// 证件类型

			tempStr = new String(pucCHMsg,"UTF-16LE");//128

			IDType = new String(tempStr.substring(124,125).getBytes("UTF-8")).trim();
			
			if(IDType.equals("I")){
				//2017版外国人永久居留证
				//英文姓名
				EngName = new String(tempStr.substring(0,60).getBytes("UTF-8")).trim();
				//性别
				SexCode = new String(tempStr.substring(60,61).getBytes("UTF-8")).trim();
				int temp = Integer.valueOf(SexCode);
				if(temp == 1){
					Sex = "男";
				}else if(temp == 2){
					Sex = "女";
				}else if (temp == 9){
					Sex = "未说明";//9
				}else{
					Sex = "未知";
				}
				//永久久留证号码
				ID = new String(tempStr.substring(61,76).getBytes("UTF-8")).trim();
				//国籍或所在地区代码

				NationalityCode = new String(tempStr.substring(76,78).getBytes("UTF-8")).trim();
				Nationality = getNationality(NationalityCode);
				//中文姓名
				Name = new String(tempStr.substring(78,94).getBytes("UTF-8")).trim();
				//证件签发日期
				StartDate = new String(tempStr.substring(94,102).getBytes("UTF-8")).trim();//16
				//证件终止日期
				EndDate = new String(tempStr.substring(102,110).getBytes("UTF-8")).trim();//16
				//出生日期
				Birthday = new String(tempStr.substring(110,118).getBytes("UTF-8")).trim();//16
				//证件版本号
				SignNum = new String(tempStr.substring(118,120).getBytes("UTF-8")).trim();//4
				//当次申请受理机关代码
				Issue = new String(tempStr.substring(120,124).getBytes("UTF-8")).trim();
				//证件类型标识符

				//预留项
				Reverse = new String(tempStr.substring(125,128).getBytes("UTF-8")).trim();
				
			}else if(IDType.equals("Y")){
				//新版外国人永久居留证
				//中文姓名
				Name = new String(tempStr.substring(0,15).getBytes("UTF-8")).trim();
				//性别
				SexCode = new String(tempStr.substring(15,16).getBytes("UTF-8")).trim();
				int temp = Integer.valueOf(SexCode);
				if(temp == 1){
					Sex = "男";
				}else if(temp == 2){
					Sex = "女";
				}else if (temp == 9){
					Sex = "未说明";//9
				}
				else{
					Sex = "未知";//0
				}
				//换证次数
				SignNum = new String(tempStr.substring(16,18).getBytes("UTF-8")).trim();//4
				//出生日期
				Birthday = new String(tempStr.substring(18,26).getBytes("UTF-8")).trim();//16

				//英文姓名
				EngName = new String(tempStr.substring(26,61).getBytes("UTF-8")).trim();
				//证件号码
				ID = new String(tempStr.substring(61,79).getBytes("UTF-8")).trim();
				//预留项
				Issue = new String(tempStr.substring(79,94).getBytes("UTF-8")).trim();
				//证件签发日期
				StartDate = new String(tempStr.substring(94,102).getBytes("UTF-8")).trim();//16
				//证件终止日期
				EndDate = new String(tempStr.substring(102,110).getBytes("UTF-8")).trim();//16
				//英文姓名备用
				Reverse2 = new String(tempStr.substring(110,121).getBytes("UTF-8")).trim();
				if (Reverse2.length() > 0)//如果有备用
				{
					EngName = new String(tempStr.substring(26,61).getBytes("UTF-8"));//不能去除空格
					EngName += Reverse2;
				}
				//国籍或所在地区代码
				NationalityCode = new String(tempStr.substring(121,124).getBytes("UTF-8")).trim();
				Nationality = getNationality(NationalityCode);
				//证件类型标识符 Y

				//既往版本外国人永久居留证件号码关联项6,7,14
				Reverse = new String(tempStr.substring(125,128).getBytes("UTF-8")).trim();
				if (Reverse.length() > 0){
					IDNum = CalForeignerID(NationalityCode,ID,Reverse);
				}
			}else if(IDType.equals("J")){
				//港澳台
				//中文姓名
				Name = new String(tempStr.substring(0,15).getBytes("UTF-8")).trim();
				//性别
				SexCode = new String(tempStr.substring(15,16).getBytes("UTF-8")).trim();
				int temp = Integer.valueOf(SexCode);
				if(temp == 1){
					Sex = "男";
				}else if(temp == 2){
					Sex = "女";
				}else if (temp == 9){
					Sex = "未说明";//9
				}else{
					Sex = "未知";
				}
				//名族
				//Nation = new String(tempStr.substring(16,18).getBytes("UTF-8")).trim();
				//出生日期
				Birthday = new String(tempStr.substring(18,26).getBytes("UTF-8")).trim();
				//住址
				Addr = new String(tempStr.substring(26,61).getBytes("UTF-8")).trim();
				//公民身份号码
				ID = new String(tempStr.substring(61, 79).getBytes("UTF-8")).trim();
				//签发机关
				Issue = new String(tempStr.substring(79,94).getBytes("UTF-8")).trim();
				//有效期起始日期
				StartDate = new String(tempStr.substring(94,102).getBytes("UTF-8")).trim();
				//有效期截止日期
				EndDate = new String(tempStr.substring(102,110).getBytes("UTF-8")).trim();
				//通行证号码
				PassID = new String(tempStr.substring(110,119).getBytes("UTF-8")).trim();
				//签发次数
				SignNum =  new String(tempStr.substring(119,121).getBytes("UTF-8")).trim();			
				//预留区
				Reverse = new String(tempStr.substring(121,128).getBytes("UTF-8")).trim();
			}else{
				//身份证
				
				//中文姓名
				Name = new String(tempStr.substring(0,15).getBytes("UTF-8")).trim();
				//性别
				SexCode = new String(tempStr.substring(15,16).getBytes("UTF-8")).trim();
				int temp = Integer.valueOf(SexCode);
				if(temp == 1){
					Sex = "男";
				}else if(temp == 2){
					Sex = "女";
				}else if (temp == 9){
					Sex = "未说明";//9
				}else{
					Sex = "未知";
				}
				//名族
				//Nation = NATION_TABLE[Integer.valueOf(new String(tempStr.substring(16,18).getBytes("UTF-8")).trim())];
				NationCode = new String(tempStr.substring(16,18).getBytes("UTF-8")).trim();
				Nation = getNation(Integer.valueOf(NationCode));
				//出生日期
				Birthday = new String(tempStr.substring(18,26).getBytes("UTF-8")).trim();
				//住址
				Addr = new String(tempStr.substring(26,61).getBytes("UTF-8")).trim();
				//公民身份号码
				ID = new String(tempStr.substring(61, 79).getBytes("UTF-8")).trim();
				//签发机关
				Issue = new String(tempStr.substring(79,94).getBytes("UTF-8")).trim();
				//有效期起始日期
				StartDate = new String(tempStr.substring(94,102).getBytes("UTF-8")).trim();
				//有效期截止日期
				EndDate = new String(tempStr.substring(102,110).getBytes("UTF-8")).trim();
				//预留区
				Reverse = new String(tempStr.substring(110,128).getBytes("UTF-8")).trim();
			}			
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -2;
		}
		 return 0;
	 }
	 
	 public String ParseIDFpMsg(byte []pucFpMsg,int len){
		 String fpmsg = "";
		 if(pucFpMsg.length < 1024 || len != 1024){
			 return fpmsg;
		 }
		 //左手1024字节 右手1024字节
		 fpmsg = bytesToHexString(pucFpMsg,len);
		 
		 return fpmsg;
	 }
	 
	 public int ParseIDPHMsg(byte []pucPHMsg,int len){
		 if(pucPHMsg.length < 1024 || len != 1024){
			 return -1;
		 }
		 //身份证解码库
		 //int ret = IDCReaderSDK.Wlt2Bmp(pucPHMsg);
		 int ret = IDCReaderSDK.GetBmp(pucPHMsg);
		 if(ret == 1){
			 return 1;
		 }
		 return ret;
	 }
}
